#pragma once

namespace pb { namespace cfg {

    class Config;

    class Value
    {
        friend class Config;

    protected:
        
//_____________________________________________________________________________
///////////////////////////////////////////////////////////////////////////////
// Any modification to this enumeration will make loading and saving failed. //
// So, any modfication wants to be approved by me. Thanks.                   //
//                                                                           //
// -Andy.Fang@gmail.com                                                      //
//___________________________________________________________________________//
        enum EType
        {
            eStr = 0,
            eInt32,

            // === Bottom ===
            eNumTypes
        };
//_____________________________________________________________________________
///////////////////////////////////////////////////////////////////////////////

        Value(Config* ,const std::string& name, const EType);
        virtual ~Value();

    protected:
        void save(std::fstream&);

        EType type() const;
        bool valid() const;

        virtual bool loadData(std::fstream&) = 0;
        virtual void saveData(std::fstream&) = 0;

        bool lengthOfName(const unsigned int);
        bool lengthOfData(const unsigned int);

    protected:
        Config*             m_cfg;

    private:
        unsigned int        m_lengthOfName;
        std::string         m_name;
        const EType         m_type;
        unsigned int        m_lengthOfData;
    };

}}